#!/usr/bin/env python
# -*- coding:utf-8 -*-
# author:MaLiang
# datetime:2020/7/22 18:52
# software: PyCharm
import pandas as pd
import numpy as np
from impala.dbapi import connect
import sys

def impala_conn_exec(sql):
  conn = connect(host='192.168.10.111', port=21050,database='ods')
  cur = conn.cursor()
  cur.execute(sql)
  data_list=cur.fetchall()
  return data_list



if __name__ == "__main__":
    conn = connect(host='192.168.10.111', port=21050, database='ods')
    cur = conn.cursor()

    dt = {
        'id': [2, 3, 4, 5, 6, 7, 8, 9, 10],
        'name': ['java', 'python', 'scala', 'hive', 'impala', 'spark', 'flink', 'hbase', 'golang']
    }
    df = pd.DataFrame(dt)
    # sql = "select * from ods_dl_seismic"
    # cur.execute(sql)
    # data_list = cur.fetchall()
    # print(data_list)

    insert_sql = "insert into test (id,name) values (?,?);"
    for row in df.itertuples():
        print(type(getattr(row, 'id')), getattr(row, 'name'))
        cur.execute(insert_sql, (getattr(row, 'id'), getattr(row, 'name')))




